From f881aff5f9993c3a6b4b0d8ed7e67d2f812f39d6 Mon Sep 17 00:00:00 2001
From: Sebastien Castiel <sebastien@castiel.me>
Date: Tue, 19 Dec 2023 09:44:09 -0500
Subject: Revert "Use modal dialogs for expense creation & edition (#10)"

This reverts commit 1e66efe5169dfad9a0c62ba42fbf31ce977bf49e.
---
 src/app/groups/[groupId]/expenses/create/page.tsx | 27 +++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 src/app/groups/[groupId]/expenses/create/page.tsx

(limited to 'src/app/groups/[groupId]/expenses/create/page.tsx')

diff --git a/src/app/groups/[groupId]/expenses/create/page.tsx b/src/app/groups/[groupId]/expenses/create/page.tsx
new file mode 100644
index 0000000..e603e59
--- /dev/null
+++ b/src/app/groups/[groupId]/expenses/create/page.tsx
@@ -0,0 +1,27 @@
+import { ExpenseForm } from '@/components/expense-form'
+import { createExpense, getGroup } from '@/lib/api'
+import { expenseFormSchema } from '@/lib/schemas'
+import { Metadata } from 'next'
+import { notFound, redirect } from 'next/navigation'
+
+export const metadata: Metadata = {
+  title: 'Create expense',
+}
+
+export default async function ExpensePage({
+  params: { groupId },
+}: {
+  params: { groupId: string }
+}) {
+  const group = await getGroup(groupId)
+  if (!group) notFound()
+
+  async function createExpenseAction(values: unknown) {
+    'use server'
+    const expenseFormValues = expenseFormSchema.parse(values)
+    await createExpense(expenseFormValues, groupId)
+    redirect(`/groups/${groupId}`)
+  }
+
+  return <ExpenseForm group={group} onSubmit={createExpenseAction} />
+}
-- 
cgit v1.3

